//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.ScientificWorkflow.ManagementStudioControls
{
    using System.Windows.Controls;
    using Microsoft.Research.ScientificWorkflow.ManagementStudioControls.RegistryManagerModule;
    using Microsoft.Research.ScientificWorkflow.ManagementStudioModels;

    /// <summary>
    /// Interaction logic for GroupCatalogCenterPane.xaml
    /// </summary>
    public partial class GroupCatalogCenterPane : UserControl
    {
        public GroupCatalogCenterPane()
        {
            InitializeComponent();
        }

        private void OnCredentialsSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            GroupCenterPanePresenter presenter = this.DataContext as GroupCenterPanePresenter;
            if (presenter != null)
            {
                ListBox credentialListBox = sender as ListBox;
                if (credentialListBox != null)
                {
                    presenter.SelectedCredentials = credentialListBox.SelectedItem as LogOnCredentialModel;
                }
            }
        }

        private void OnUsersSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            GroupCenterPanePresenter presenter = this.DataContext as GroupCenterPanePresenter;
            if (presenter != null)
            {
                ListBox userListBox = sender as ListBox;
                if (userListBox != null)
                {
                    presenter.SelectedUser = userListBox.SelectedItem as SearchUserModel;
                }
            }
        }
    }
}
